#include<bits/stdc++.h>
#include<string>
#include<sstream>
using namespace std;

string w;
string sen;
int main(){
	getline(cin,w);
	int len=w.length();
	for(int i=0;i<len;i++){
		if(w[i]>='A'&&w[i]<='Z'){
			int c=w[i]-'A';
			w[i]='a'+c;
		}
	}
	getline(cin,sen);
	istringstream iss(sen);
	string token;
	int sum=0,k=INT_MAX;
	bool find=false;
	int j=0;
	while(iss>>token){
		while(!find&&sen[j]==' ') j++;
		//match
		if(token.length()==len){
			int i=0;
			while(w[i]!='\0'){
				if(token[i]>='A'&&token[i]<='Z'){
					int c=token[i]-'A';
					token[i]='a'+c;
				};
				if(token[i]!=w[i]) break;
				i++;
			}
			if(w[i]=='\0'){
				sum++;
				if(!find){
					k=j;
					find=true;
				}
			}
		};
		while(!find&&sen[j]!=' ') j++;
	}
	if(sum==0){
		cout<<-1;
	}
	else{
		cout<<sum<<' '<<k;
	}
	return 0;
}
/*
To
 to be or not  to  be is a question
*/
